package testadventure;


import edu.clemson.cs.hamptos.adventure.AdventureCommand;
import edu.clemson.cs.hamptos.adventure.AdventureEngine;
import edu.clemson.cs.hamptos.adventure.AdventureTarget;
import edu.clemson.cs.hamptos.adventure.AdventureWindow;
import edu.clemson.cs.hamptos.adventure.VerbStrategyAlt;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *<p>this is an implentation of VeryStrategyAlt
 *this class checks to see if the verb being directed to a disabled object then 
 * the statement will have no effect.
 * Also checks to see if the verb directed to the object allows the player to use
 * it</p>
 * .
 * <p>if the pistol is not loaded, it will not be able to be picked up.</p>
 * 
 */
public class VerbApplyTool implements VerbStrategyAlt {
    /**
     * 
     */
    protected final HashSet<String> verbs = new HashSet<String>();
    VerbApplyTool()
    {
        verbs.add("break");
    }

    @Override
    public void doCommand(AdventureCommand c, AdventureEngine e, AdventureWindow w) {
        AdventureTarget thedo = c.getDirectObject();
        AdventureTarget theio = c.getIndirectObject();
        
        HashMap<String, Integer> dostats = thedo.getStats();
        HashMap<String, Integer> iostats = theio.getStats();
        
        //see if do is defeated or still active
        if (dostats.get("enabled") == 0)
        {
            w.println(thedo.getShortDescription() + " is already disabled.");
            return;
        }
        
        //see if io has enough stuff to act
        if(iostats.get("charges") == 0)
        {
            w.println(theio.getShortDescription() + " is not usable right now.");
            return;
        }
        
        //alter the stats accordingly
        w.println("You " + c.getVerb() + " " + thedo.getShortDescription() 
                + " with " + theio.getShortDescription() + ".");
        if(iostats.get("charges") > 0)
        {
            theio.listen(e, w);
        }
        thedo.listen(e, w);
    }

    @Override
    public String getName() {
        return "VerbApplyTool";
    }

    @Override
    public Set<String> getVerbs() {
        return new HashSet<String>(verbs);
    }
}
